<template>
  <div>
    <!-- 顶部搜索区域 -->
    <el-card>
      <el-form v-model="searchDate" ref="searchRef" label-width="100px" class="demo-ruleForm">
        <el-row class="demo-ruleForm-row">
          <el-col :span="6">
            <el-form-item label="项目名称" prop="name">
              <el-input placeholder="请输入招标项目名称" v-model="searchDate.name" clearable></el-input>
            </el-form-item>
          </el-col>
           <el-col :span="6">
            <el-form-item label="分包编号" prop="subcontract">
              <el-input placeholder="请输入分包编号" v-model="searchDate.subcontract" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="参投单位" prop="company_name">
              <el-input placeholder="请输入参投单位" v-model="searchDate.company_name" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4" >
            <div class="search_col">
              <el-button type="primary" size="mini" icon="el-icon-search">搜索</el-button>
              <el-button type="primary" size="mini" icon="el-icon-refresh" @click="resetForm">重置</el-button>
            </div>
          </el-col>
        </el-row>
      </el-form>
    </el-card>

    <!-- 卡片视图区域 -->
    <el-card>
      <div class="left">
        <el-button type="primary" size="mini" icon="el-icon-upload">批量导入</el-button>
      </div>
      <el-table :data="tableData" :row-class-name="tableRowClassName" 
      style="width: 100%" border
      :header-cell-style="{
          'background-color': '#CBD9EC',
          color: '#fff',
          'font-weight': '400',
      }"
      @selection-change="handleSelectionChange">
        <el-table-column
          type="selection"
          width="55">
        </el-table-column>
        <el-table-column label="序号" width="75" type="index"></el-table-column>
        <el-table-column prop="name" label="招标项目名称" width="240"></el-table-column>
        <el-table-column prop="subcontract" label="分包编号"> </el-table-column>
        <el-table-column prop="" label="包名称（部位）"></el-table-column>
        <el-table-column prop="subcontracted" label="分标项目名称"> </el-table-column>
        <el-table-column prop="company_name" label="参投单位" width="120"> </el-table-column>
        <el-table-column prop="offer" label="最终报价(万元)" width="120"> </el-table-column>
        <el-table-column prop="approve" label="最终折扣" width="120"> </el-table-column>
        <el-table-column prop="prize" label="是否中标" width="120"> </el-table-column>
        <el-table-column prop="winning" label="中标金额(万元)"> </el-table-column>
        <el-table-column prop="server" label="应收中标服务费(元)" width="120"> </el-table-column>
        <el-table-column prop="ensure" label="实收保证金(元)"> </el-table-column>
        <el-table-column prop="price" label="应收保证金（标书规定缴纳金额）(元)"> </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button type="primary" size="mini" @click="importClick(scope.row)">同意导入</el-button>
          </template>
        </el-table-column>
      </el-table>

      <!-- 分页 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="page.mount"
        :page-sizes="[1, 3, 6, 10]"
        :page-size="page.size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </el-card>
  </div>
</template>

<script>
export default {
  data () {
    return {
      // 搜索数据
      searchDate: {
        name: '',
        subcontract: '',
        company_name: ''
      },

      // 表格数据
      tableData: [],

      // 分页数据
      page: {
        // 每页显示几条数据
        size: 6,
        // 当前页码值
        mount: 0,
      },
      // 总数据条数
      total: 6,

      // 存储选中了的数据
      checkboxList: [],
    }
  },
  methods: {
    // 重置事件
    resetForm() {
      this.searchDate.name = '';
      this.searchDate.subcontract = '';
      this.searchDate.company_name = '';
    },

    // 每页数据显示条数改变时触发
    handleSizeChange(newSize) {
      console.log(newSize)
    },
    // 页码值发生改变时触发
    handleCurrentChange(newPage) {
      console.log(newPage)
    },

    // 全选
    handleSelectionChange(val) {
      this.checkboxList = val;
      console.log(this.checkboxList);
    },

    // 隔行变色
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex === 1) {
        return 'warning-row'
      } else if (rowIndex === 3) {
        return 'success-row'
      }
      return ''
    },

    // 同意导入
    importClick(row) {
      console.log(row);
    }
  }
}
</script>

<style>

</style>